package com.yunji.order.emuns;

import com.yunji.common.utils.bean.BeanUtils;

import java.util.Objects;

public enum RemoteTypes {
    WECHAT_JSAPI_PAYABLE(1101, "微信JSAPI支付"),
    WECHAT_APP_API_PAYABLE(1102, "微信APP支付"),
    WECHAT_H5API_PAYABLE(1103, "微信H5API支付"),
    WECHAT_NATIVE_PAYABLE(1104, "微信Native支付"),
    WECHAT_APPLET_PAYABLE(1105, "微信小程序支付"),
    WECHAT_TRADE_PAYOUT(1201, "微信转账"),
    WECHAT_TRADE_REFUND(1301, "微信退款"),
    WECHAT_TRADE_DELIVERED(1401, "微信发货"),
    ALIPAY_JSAPI_PAYABLE(2101, "支付宝JSAPI支付"),
    ALIPAY_H5API_PAYABLE(2102, "支付宝H5API支付"),
    ALIPAY_APP_API_PAYABLE(2103, "支付宝APP支付"),
    ALIPAY_NATIVE_PAYABLE(2104, "支付宝Native支付"),
    ALIPAY_PC_API_PAYABLE(2106, "支付宝网站支付"),
    ALIPAY_TRADE_PAYOUT(2201, "支付宝转账"),
    ALIPAY_TRADE_REFUND(2301, "支付宝退款");
    private final Integer code;
    private final String text;

    RemoteTypes(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public Integer getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static String get(Integer code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        RemoteTypes[] enums = RemoteTypes.values();
        for (RemoteTypes e : enums) {
            if (Objects.equals(e.code, code)) {
                return e.text;
            }
        }
        return null;
    }
}
